package cn.sh.library.gmwx.controller;

import org.apache.log4j.Logger;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.sh.library.gmwx.common.ApiConstants;
import cn.sh.library.gmwx.common.CodeMsgUtil;

import java.util.Map;
import java.util.TreeMap;

public abstract class BaseController {
    private Logger logger = Logger.getLogger(this.getClass());
    
 // place详细信息接口
 	public String placeDetailApi =ApiConstants.placeDetailApi;

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Map<String, String> exceptionHandler(Exception e){
    	e.printStackTrace();
        logger.error(e.getLocalizedMessage(), e);
        Map<String, String> result = new TreeMap<String, String>();
        result.put("status", "error");
        String message = e.getLocalizedMessage();
        message = "<font color='red'>" + message + "</font>";
        result.put("msg", message);
        return result;
    }

//    protected Subject getSubject(){
//        return SecurityUtils.getSubject();
//    }
}
